package Text;

public class Demo7 {
    public static void main(String[] args) {
        String str = "";//水仙花数集
        for (int i = 100; i < 999; i++) {//遍历三位数
            int bai = i / 100;
            int shi = i % 100 / 10;
            int ge = i % 100 % 10;

//            System.out.println(i+","+bai+","+shi+","+ge);
            double j = Math.pow(bai, 3) + Math.pow(shi, 3) + Math.pow(ge, 3);
//            System.out.print(j+",");

            if (i==j){//判断是否为水仙花数
                str = str+i+" ";//进行拼接
            }
        }
        System.out.println("水仙花数为："+str);
    }
}
